// blacklist.js
var localData = require('../../data/996blacklist.js')
var initList = []

Page({
  data: {
    isLoadMore: true,
    isReachBottom: true,
    blackList: [],
    currentNo: 5,
    isHideModalView: true,
    comurl: '/images/company/pdd-logo.png'
  },
  onLoad: function () {
    var totalList = localData.blackList
    console.log(totalList)
    // 初始化显示前五个
    for (var i = 0; i < 5; i++) {
      initList.push(totalList[i])
    }
    this.setData({
      blackList: initList
    })
  },
  onReachBottom: function () { // 上拉加载更多
    this.setData({
      isLoadMore: false
    })
    var totalList = localData.blackList
    var currentNo = this.data.currentNo
    var initList = []
    if (currentNo >= 25) {
      this.setData({
        isLoadMore: true,
        isReachBottom: false
      })
      return
    }
    for (var i = 0; i < currentNo + 5; i++) {
      initList.push(totalList[i])
    }
    setTimeout(() => {
      this.setData({
        currentNo: currentNo + 5,
        isLoadMore: true,
        blackList: initList
      })
    }, 1000)
  },
  toCompanyWeb: function (e) {
    var comsite = e.currentTarget.dataset.comsite
    // 由于个人主体小程序无法跳转外部链接,点击复制到剪贴板
    wx.setClipboardData({
      data: comsite,
      success(res) {
        wx.getClipboardData({
          success(res) {
            wx.showToast({
              title: '官网已复制'
            })
          }
        })
      }
    })
  }, 
  toProofWeb: function (e) {
    var comurl = e.currentTarget.dataset.comurl
    // 由于个人主体小程序无法跳转外部链接,点击复制到剪贴板
    wx.setClipboardData({
      data: comurl,
      success(res) {
        wx.getClipboardData({
          success(res) {
            wx.showToast({
              title: '网址已复制'
            })
          }
        })
      }
    })
  },
  onShareAppMessage: function () { //用户点击右上角分享   
    return {
      title: '996ICU', // 标题
      desc: '996ICU分享', // 描述
      imageUrl: "/images/material/share-image.png", // 缩略图
      path: 'pages/index/index' // 路径
    }
  },
  longPress: function (e) {
    this.setData({
      isHideModalView: false,
      comurl: e.currentTarget.dataset.imgurl
    })
  },
  hideModalView: function (e) {
    if (e.target.dataset.target != 'self') {
      this.setData({
        isHideModalView: true
      })
    }
  },
  onHide: function () {
    this.setData({
      isHideModalView: true
    })
  },
})
